#!/usr/bin/env python

from distutils.core import setup, Extension
import os

## Windows (32), Python 2.6, with GCC (MinGW or Cygwin) Only, for now
if os.name == "nt":
    ## Constants
    library_dirs = [os.path.abspath('lib/win32')]
    include_dirs = [os.path.abspath('ext/include'), os.path.abspath(os.path.join(os.sys.exec_prefix + 'include'))]

    ## Configure Extensions
    fltime  = Extension('fltime', include_dirs=include_dirs,
                        sources=['ext/fltime.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/fltime.lib,--export-all-symbols'])
    
    flmath  = Extension('flmath', include_dirs=include_dirs,
                        sources=['ext/flmath.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/flmath.lib,--export-all-symbols'])
    
    flcolor = Extension("flcolor", include_dirs=include_dirs,
                        sources=['ext/flcolor.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/flcolor.lib,--export-all-symbols'])

    image   = Extension('image', libraries=['opengl32', 'glu32', 'DevIL', 'ILU'],
                        library_dirs=library_dirs,
                        include_dirs=include_dirs,
                        sources=['ext/image.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/image.lib,--export-all-symbols'])

    mesh    = Extension('mesh', libraries=['flmath'],
                        library_dirs=library_dirs,
                        include_dirs=include_dirs,
                        sources=['ext/mesh.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/mesh.lib,--export-all-symbols'])

    sprite  = Extension('sprite', libraries=['flcolor', 'flmath', 'image', 'mesh'],
                        library_dirs=library_dirs,
                        include_dirs=include_dirs,
                        sources=['ext/sprite.c'],
                        extra_link_args=['-Wl,--out-implib=lib/win32/sprite.lib,--export-all-symbols'])

    screen  = Extension('screen', libraries=['opengl32', 'SDL', 'flcolor', 'flmath', 'sprite'],
                        library_dirs=library_dirs,
                        include_dirs=include_dirs,
                        sources=['ext/screen.c'])

    ext_modules = [fltime, flmath, flcolor, image, mesh, sprite, screen]

elif os.name == "mac":
    pass

elif os.name == "posix":
    pass

## Setup
if __name__ == "__main__":
    setup(ext_modules=ext_modules)
